package net.orange.architecture.web;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpServlet;

import net.orange.console.schedule.Schedule;

/**
 * The system startup listener - which initialize the system, like start up the
 * schedule job.
 */
public class StartupListener extends HttpServlet implements
		ServletContextListener {

	private static final long serialVersionUID = 3981745934343208680L;

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent sce) {
		try {
			Schedule.startAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent sce) {
		try {
			Schedule.stopAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}